<?php defined('SYSPATH') OR die('No direct access allowed.') ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网络课程后台管理系统</title>
<?php echo HTML::style('statics/styles/admin/commom.css') ?>
<style type="text/css">
/* Panel */
#panel { height:100%; overflow:hidden;}
#panel .column { position:relative; top:-8px;}

#top { height:98px; color:#2C88D2; background:url(<?php echo URL::site('statics/images/admin') ?>/top_bg.jpg) repeat-x;}
#top .logo { position:absolute; left:0;}
#top .info { position:absolute; right:30px; top:40px;}
#top a { color:#2C88D2;}

#menu { float:left; width:183px; background:url(<?php echo URL::site('statics/images/admin') ?>/menu_bg.jpg) repeat-y;}
#menu div.tools { padding-top:3px; text-align:center;}
#menu dl { margin-top:8px; margin-left:7px; width:170px;}
#menu dt { height:34px; font-size:14px; line-height:34px; text-align:center; background:url(<?php echo URL::site('statics/images/admin') ?>/menu_dt_bg.jpg) no-repeat;}
#menu dt a { position:relative; display:block; color:#09C; font-weight:bold; text-decoration:none;}
#menu dt span { float:right; margin:13px 10px 0 0; width:9px; height:9px; overflow:hidden;}
#menu dt span.folded { background:url(<?php echo URL::site('statics/images/admin') ?>/menu_dt_icons.gif) no-repeat 0 -9px;}
#menu dt span.expanded { background:url(<?php echo URL::site('statics/images/admin') ?>/menu_dt_icons.gif) no-repeat;}
#menu dd { display:none;}
#menu dd a { margin-left:30px; padding-left: 30px; color:#888; background:transparent url(<?php echo URL::site('statics/images/admin') ?>/icons.gif) no-repeat scroll 15px -45px;}
#menu li.item { margin-top:1px; line-height:31px; background:url(<?php echo URL::site('statics/images/admin') ?>/menu_item_bg.jpg) no-repeat;}
#menu ul.sub { border-bottom:1px solid #D5E5EB; background:url(<?php echo URL::site('statics/images/admin') ?>/menu_sub_bg.jpg) repeat-x;}
#menu ul.sub li { padding:5px 0; line-height:1em;}

#main { margin-left:183px;}

#footer { clear:both; height:1px;}
</style>
<?php echo HTML::script('statics/scripts/jquery-1.3.2.min.js') ?>
<?php echo HTML::script('statics/scripts/admin/common.js') ?>
<script type="text/javascript">
// 浏览器窗口尺寸变化的同事也调整面板的内部尺寸
jQuery(window).resize(function() {
    Panel.adjust();
});

jQuery(function($) {
    // 调整面板的内部尺寸
    Panel.adjust();
    // 隐藏虚线框
    $(".nofocus").click(function() {
        $(this).blur();
    });
    // 单个菜单展开/收缩
    $("#menu dt > a").click(function() {
        return Menu.toggle(this);
    });
    // 展开第一个菜单
    Menu.expandFirst();
});


/**
 * 面板相关函数
 */
var Panel = {
    adjust: function() {
        var height = document.documentElement.clientHeight - 98;
        jQuery("#menu, #main").height(height);
    }
};

/**
 * 菜单相关函数
 */
var Menu = {
    expandFirst: function() {
        jQuery("#menu dd:eq(0)").show();
        jQuery("#menu dt:eq(0) span").removeClass("folded").addClass("expanded");
    },
    hideAll: function() {
        jQuery("#menu dl > dd").hide();
        jQuery("#menu dt span").removeClass("expanded").addClass("folded");
        return false;
    },
    toggle: function(obj) {
        var sub = jQuery(obj).parents("dt").next("dd");
        var icon = jQuery("span", obj);

        if (sub.length == 0) {
            return false;
        }

        if (sub.css("display") == "none") {
            Menu.hideAll();
            sub.show();
            icon.removeClass("folded").addClass("expanded");
        } else {
            sub.hide();
            icon.removeClass("expanded").addClass("folded");
        }
        return false;
    }
}
</script>
</head>

<body>

<div id="panel">
    <div id="top">
        <div class="logo"><a href="<?php echo URL::site('admin') ?>" class="nofocus"><?php echo HTML::image('statics/images/admin/top_logo.jpg', array('alt' => "返回后台首页")) ?></a></div>
        <div class="info">
            <span>欢迎 <strong><?php echo Auth::get_name() ?></strong> 回来！</span>
            [ <a href="<?php echo URL::site('admin/default') ?>" target="main">后台首页</a> ]
            [ <a href="<?php echo URL::base() ?>" target="_top">网站首页</a> ]
            [ <a href="<?php echo URL::site('admin/logout') ?>">退出</a> ]
        </div>
    </div>

    <div id="menu" class="column">
        <dl>
            <?php foreach (Kohana::config('admin/menu') as $menu): ?>
            <dt><a href="javascript:void(0);"><span class="folded"></span><?php echo $menu['title'] ?></a></dt>
            <dd>
                <ul>
                    <?php foreach ((array)$menu['items'] as $link): ?>
                    <li class="item"><a href="<?php echo URL::site("admin/{$link['url']}") ?>" target="main"><?php echo $link['text'] ?></a></li>
                    <?php endforeach ?>
                </ul>
            </dd>
            <?php endforeach ?>
        </dl>
    </div>

    <div id="main" class="column">
        <iframe name="main" src="<?php echo URL::site('admin/default') ?>" height="100%" scrolling="auto" frameborder="0" width="100%" height="100%" />
    </div>
</div>

</body>
</html>